let dataTime = (time) => {
    let timestamp = Date.parse(new Date())
    let val1 = timestamp - time
    if (val1 > 86400000) {
        return time = new Date(parseInt(time)).toJSON().slice(0, 10)
    } else if (val1 > 3600000) {
        return time = parseInt((val1 % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)) + '小时前'
    } else if (val1 < 60000) {
        return time = '刚刚'
    } else {
        return time = parseInt((val1 % (1000 * 60 * 60)) / (1000 * 60)) + '分钟前'
    }
}
let time = (value) => {
    let date = new Date(value);
    let y = date.getFullYear();
    let m = date.getMonth() + 1;
    m = m < 10 ? ('0' + m) : m;
    let d = date.getDate();
    d = d < 10 ? ('0' + d) : d;
    let h = date.getHours();
    h = h < 10 ? ('0' + h) : h;
    let minute = date.getMinutes();
    let second = date.getSeconds();
    minute = minute < 10 ? ('0' + minute) : minute;
    second = second < 10 ? ('0' + second) : second;
    return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;

}
let time1 = (value) => {
    let date = new Date(value);
    let y = date.getFullYear();
    let m = date.getMonth() + 1;
    m = m < 10 ? ('0' + m) : m;
    let d = date.getDate();
    d = d < 10 ? ('0' + d) : d;
    let h = date.getHours();
    h = h < 10 ? ('0' + h) : h;
    let minute = date.getMinutes();
    let second = date.getSeconds();
    minute = minute < 10 ? ('0' + minute) : minute;
    second = second < 10 ? ('0' + second) : second;
    return y + '-' + m + '-' + d
}
let time2 = (value) => {
    let date = new Date(value);
    let m = date.getMonth() + 1;
    m = m < 10 ? ('0' + m) : m;
    let d = date.getDate();
    d = d < 10 ? ('0' + d) : d;
    return m + '-' + d
}
let time3 = (value) => {
    let date = new Date(value);
    let y = date.getFullYear();
    let m = date.getMonth() + 1;
    m = m < 10 ? ('0' + m) : m;
    let d = date.getDate();
    d = d < 10 ? ('0' + d) : d;
    let h = date.getHours();
    h = h < 10 ? ('0' + h) : h;
    let minute = date.getMinutes();
    let second = date.getSeconds();
    minute = minute < 10 ? ('0' + minute) : minute;
    second = second < 10 ? ('0' + second) : second;
    return y + '-' + m + '-' + d + ' ' + h + ':' + minute;
}
let time4 = (value) => {
    let date = new Date(value);
    let h = date.getHours();
    h = h < 10 ? ('0' + h) : h;
    let minute = date.getMinutes();
    minute = minute < 10 ? ('0' + minute) : minute;
    return h + ':' + minute
}
let time5 = (value) => {
    let date = new Date(value);
    let y = date.getFullYear();
    return y
}
/* 时间倒计时 */
let countDown = (v) => {
    let minutes = parseInt((v % (1000 * 60 * 60)) / (1000 * 60))
    let seconds = (v % (1000 * 60)) / 1000
    return minutes + " 分 " + seconds + " 秒 "
}
export {
    dataTime,
    time,
    time1,
    time2,
    time3,
    time4,
    time5,
    countDown   
}